#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <opencv2/opencv.hpp>
#include <QTimer>
#include <QAction>
#include <QMenu>
#include <list>
#include "editform.h"
#include "writevideo.h"
#include "cvxtext.h"

using namespace std;
using namespace cv;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void initInterface();
    void initVideo(QString video_path);
    void menuInit();
    void showMenu();


private slots:
    void on_action_file_open_triggered();

    void on_action_file_save_triggered();

    void on_action_exit_triggered();

    void on_pushButton_start_clicked();

    void on_pushButton_stop_clicked();

    void on_pushButton_replay_clicked();

    void on_horizontalSlider_timeline_valueChanged(int value);

    void playVideo();

    void updateSliderValue(int value);

    void editFrame();

    void editClosed();

    void handleResults(int value);

protected:
    void mousePressEvent(QMouseEvent *event);
    void closeEvent(QCloseEvent *event);

private:
    Ui::MainWindow *ui;
    QTimer time_video;
    string path_open;
    string path_save;
    double total_frame_number;
    double speed;
    bool isplaying;
    VideoCapture capture;
    Mat frame;
    QMenu rightbtn_menu;
    QAction play;
    QAction edit;
    EditForm *editform;
    double width;
    double height;
    int rate;
    int minute;
    int second;
    int state;
    list<SubtitleInfo> l_subtitle;
    list<BoxInfo> l_box;
    QString str_time;
    CvxText *cvtext;

signals:
    void currentValue(int value);
};

#endif // MAINWINDOW_H
